#pragma once
#include "RoadLineDesign.h"
#include "RoadTerrian.h"
#include "RoadCrossSectionalDesign.h"
#include "MeshObjectBase.h"
class RoadDesign: public MeshObjectBase
{
public:
	RoadDesign(PRoadTerrian pTerrain, ZMString strObjName);
	~RoadDesign();
	int LoadDataFromNode(const QDomNode& node);

	int CalRoadData();

	void SaveRoadData(const QString& strFileName);
	
	CStreamSaveData SaveRoadData();

	PRoadCrossSectionalDesign& GetCrossData() 
	{
		return m_pRoadCross;
	}

	void GetBoundCalTree(PTreeTri& pTree, ZMVector<ZMTriangle>::iterator& triBegin)
	{
		m_pRoadCross->GetBoundCalTree(pTree, triBegin);
	}

	void GetRoadBoundSideTree(const RoadCrossBase::CrossSide& side, PTreeSeg& pTree, ZMVector<ZMSegmengt>::iterator& segBegin, int& iSize)
	{
		m_pRoadCross->GetRoadBoundSideTree(side, pTree, segBegin, iSize);
	}

	void GetRoadBoundTree(PTreeSeg& pTree, ZMVector<ZMSegmengt>::iterator& segBegin, int& iSize)
	{
		m_pRoadCross->GetRoadBoundTree(pTree, segBegin, iSize);
	}

	void AddSlopeRestrictData(const ZMString& strObjName, ZMVector<ZMPoint3D>& vPolyPnt)
	{
		m_pRoadCross->AddSlopeRestrictData(strObjName, vPolyPnt);
	}

	void AddRoadRestrictData(const ZMString& strObjName, RoadCrossBase::CrossSide side, const ZMVector<ZMPoint3D>& vPolyPnt)
	{
		m_pRoadCross->AddRoadRestrictData(strObjName, m_pTerrain, side, vPolyPnt);
	}

	void AddClearRestrictData(const ZMString& strObjName, RoadCrossBase::CrossSide side, const ZMVector<ZMPoint3D>& vPolyPnt)
	{
		m_pRoadCross->AddClearRestrictData(strObjName, m_pTerrain, side, vPolyPnt);
	}
	
	void SetTerrian(PRoadTerrian pTerrain)
	{
		m_pTerrain = pTerrain;
	}


	PRoadTerrian GetTerrian()
	{
		return m_pTerrain;
	}


	ZMVector<RoadCrossBase::suMeshData> ToMeshData(const ZMReal& uPlusDivMile = 20, const ZMReal& vPlusDivDis = 20)
	{
		return m_pRoadCross->ToMeshData(GetObjName(),uPlusDivMile, vPlusDivDis);
	}

	virtual ZMVector<SharedPointer<UIDataBase>> GetParam();
protected:
	virtual void SetParamCore(const ZMVector<SharedPointer<UIDataBase>>&  vParam);
	
	virtual ZMVector<suDrawMesh> GetMeshData(const ZMString& strMeshName = "");
private:
	PRoadTerrian m_pTerrain;
	PRoadLineDesign m_pRoadLine;
	PRoadCrossSectionalDesign m_pRoadCross;
};
typedef SharedPointer<RoadDesign> PRoadDesign;

